home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / Alpha 6.5.sit / Tcl / UserCode / parray.tcl < prev    next >
Text File  |  1996-08-15  |  1KB  |  33 lines

  1. # parray:
  2. # Print the contents of a global array on stdout.
  3. #
  4. # $Header: /rel/cvsfiles/devo/tcl/library/parray.tcl,v 1.2 1992/12/23 15:40:10 zoo Exp $ SPRITE (Berkeley)
  5. #
  6. # Copyright 1991 Regents of the University of California
  7. # Permission to use, copy, modify, and distribute this
  8. # software and its documentation for any purpose and without
  9. # fee is hereby granted, provided that this copyright
  10. # notice appears in all copies.  The University of California
  11. # makes no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without
  13. # express or implied warranty.
  14. #
  15.  
  16. proc parray a {
  17.     upvar 1 $a array
  18.     if [catch {array size array}] {
  19.     error "¥"$a¥" isn't an array"
  20.     }
  21.     set maxl 0
  22.     foreach name [lsort [array names array]] {
  23.     if {[string length $name] > $maxl} {
  24.         set maxl [string length $name]
  25.     }
  26.     }
  27.     set maxl [expr {$maxl + [string length $a] + 2}]
  28.     foreach name [lsort [array names array]] {
  29.     set nameString [format %s(%s) $a $name]
  30.     insertText [format "%-*s = %s" $maxl $nameString $array($name)]
  31.     }
  32. }
  33.